/**
 * @mbggenerated
 * @author wujian
 */
package bearworker.zxl.dao.mapper;

import bearworker.zxl.entity.DeliveryUserReward;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface DeliveryUserRewardMapper {
    /* @mbggenerated */
    @Delete({
        "delete from delivery_user_reward",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /* @mbggenerated */
    @Insert({
        "insert into delivery_user_reward (id, user_id, ",
        "reward_money, reward_reason, ",
        "relation_id, reward_from, ",
        "wechat_ord_no, create_time)",
        "values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, ",
        "#{rewardMoney,jdbcType=INTEGER}, #{rewardReason,jdbcType=VARCHAR}, ",
        "#{relationId,jdbcType=INTEGER}, #{rewardFrom,jdbcType=TINYINT}, ",
        "#{wechatOrdNo,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP})"
    })
    int insert(DeliveryUserReward record);

    /* @mbggenerated */
    @InsertProvider(type=DeliveryUserRewardSqlProvider.class, method="insertSelective")
    int insertSelective(DeliveryUserReward record);

    /* @mbggenerated */
    @Select({
        "select",
        "id, user_id, reward_money, reward_reason, relation_id, reward_from, wechat_ord_no, ",
        "create_time",
        "from delivery_user_reward",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_money", property="rewardMoney", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_reason", property="rewardReason", jdbcType=JdbcType.VARCHAR),
        @Result(column="relation_id", property="relationId", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_from", property="rewardFrom", jdbcType=JdbcType.TINYINT),
        @Result(column="wechat_ord_no", property="wechatOrdNo", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    DeliveryUserReward selectByPrimaryKey(Integer id);

    /* @mbggenerated */
    @UpdateProvider(type=DeliveryUserRewardSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(DeliveryUserReward record);

    /* @mbggenerated */
    @Update({
        "update delivery_user_reward",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "reward_money = #{rewardMoney,jdbcType=INTEGER},",
          "reward_reason = #{rewardReason,jdbcType=VARCHAR},",
          "relation_id = #{relationId,jdbcType=INTEGER},",
          "reward_from = #{rewardFrom,jdbcType=TINYINT},",
          "wechat_ord_no = #{wechatOrdNo,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DeliveryUserReward record);
    
    @Select({
        "select",
        "id, user_id, reward_money, reward_reason, relation_id, reward_from, wechat_ord_no, ",
        "create_time",
        "from delivery_user_reward",
        "where user_id = #{userId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_money", property="rewardMoney", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_reason", property="rewardReason", jdbcType=JdbcType.VARCHAR),
        @Result(column="relation_id", property="relationId", jdbcType=JdbcType.INTEGER),
        @Result(column="reward_from", property="rewardFrom", jdbcType=JdbcType.TINYINT),
        @Result(column="wechat_ord_no", property="wechatOrdNo", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<DeliveryUserReward> selectByUserId(Integer userId);
}